import socket

class UDPclient:

    def __init__(self,ip,port):
        self.ss=socket.socket(family=socket.AF_INET,type=socket.SOCK_DGRAM)
        self.ip=ip
        self.port=port

    def send_msg(self,severip,serverport):
        msg=input('please input the message:')
        self.ss.sendto(msg.encode(),(severip,serverport))
    def reve_msg(self):
        msg,addr=self.ss.recv(65535)
        print('收到来自{}的消息{}' .format(addr,msg.decode()))
    def start(self):
        self.send_msg(self.ip,self.port)
        self.reve_msg()
        self.ss.close()

if __name__ == '__main__':
    C=UDPclient('10.2.1.60',8888)
    C.start()